package com.bert.feign;

import com.bert.entity.TestDemoEntity;
import com.bert.feign.fallBackFactory.TestClientFallback;
import com.bert.feign.fallBackFactory.TestClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(name = "provider", contextId = "provider", path = "/provider/test", fallbackFactory = TestClientFallbackFactory.class)
//@FeignClient(name = "provider-one", contextId = "provider-one", fallback = TestClientFallback.class)
public interface TestClient {

    /**
     * Call the path method of the remote provider or roll back when the service is blown.
     * @param number number
     * @return {@link String}
     */
    @GetMapping("/path/{number}")
    String path(@PathVariable("number") String number);

    /**
     * Call the divide method of the remote provider or roll back when the service is blown.
     * @param a a
     * @param b b
     * @return {@link String}
     */
    @GetMapping("/param")
    String param(@RequestParam("a") Integer a, @RequestParam("b") Integer b);

    /**
     * Test that the default method calls the remote method is still a remote call.
     * @param a a
     * @return {@link String}
     */
    default String param(Integer a) {
        return param(a, 0);
    }

    /**
     *
     * @param entity entity
     * @return {@link TestDemoEntity}
     */
    @PostMapping("/post")
    TestDemoEntity post(@RequestBody TestDemoEntity entity);

    /**
     * Call the notFound method of the remote provider or roll back when the service is blown.
     * @return {@link String}
     */
    @GetMapping("/notFound")
    String notFound();

}
